﻿/*
 *      Copyright 2011 Battams, Derek
 *       
 *       Licensed under the Apache License, Version 2.0 (the "License");
 *       you may not use this file except in compliance with the License.
 *       You may obtain a copy of the License at
 *
 *          http://www.apache.org/licenses/LICENSE-2.0
 *
 *       Unless required by applicable law or agreed to in writing, software
 *       distributed under the License is distributed on an "AS IS" BASIS,
 *       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *       See the License for the specific language governing permissions and
 *       limitations under the License.
 */
using System;
using System.Collections.Generic;
using System.Text;
using JsonExSerializer;

namespace LivePvrData.Data.Net.Responses
{
    /// <summary>
    /// If a request to the web service generates an error then it will be encapsulated in an ErrorResponse object
    /// </summary>
    public class ErrorResponse : Response
    {
        private string msg;
        private string stackTrace;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="msg">The human friendly error message</param>
        /// <param name="stackTrace">If the error generated an exception on the server side then that exception is provided here and should be passed onto the Live PVR Data team for investigation should the exception be reproducible.</param>
        public ErrorResponse(string msg, string stackTrace = null) : base(true)
        {
            this.msg = msg;
            this.stackTrace = stackTrace;
        }

        /// <summary>
        /// Do NOT use; provided for JSON serialization only
        /// </summary>
        public ErrorResponse() : base(true) { }

        /// <summary>
        /// The error message generated by the web service; this is a human readable error message
        /// </summary>
        [JsonExProperty("message")]
        public string Message { get { return msg; } protected set { msg = value; } }

        /// <summary>
        /// If the error produced on the server generated a server side exception then the stack trace will be provided here.  If you are
        /// constantly encountering an error that produces a stack trace then you should provide the stack trace to the Live PVR Data admins
        /// for problem determination.
        /// </summary>
        [JsonExProperty("stackTrace")]
        public string StackTrace { get { return stackTrace; } protected set { stackTrace = value; } }
    }
}
